/*
 * Concept.java
 * 
 * Copyright 2012 Xinli Jia
 * 
 * Concept data model
 */

package ie.dit.comp.lukejia.fyp.model;

public class Concept implements Comparable<Concept> {
	private float possibility;
	private String concept;
	private String review;

	public Concept(String t, float p, String r) {
		this.concept = t;
		this.possibility = p;
		this.review = r;
	}

	public float getPossibility() {
		return possibility;
	}

	public void setPossibility(float possibility) {
		this.possibility = possibility;
	}

	public String getConcept() {
		return concept;
	}

	public void setConcept(String text) {
		this.concept = text;
	}

	@Override
	public boolean equals(Object aThat) {
		if (this == aThat)
			return true;
		if (!(aThat instanceof Concept))
			return false;

		Concept that = (Concept) aThat;
		return this.getConcept().equals(that.getConcept());
	}
	
	@Override
	public int hashCode() {
		return concept.hashCode();
	}

	@Override
	public int compareTo(Concept o) {
		// If same phrases, return equal
		if (this.getConcept().equals(o.getConcept()))
			return 0;
		// Higher possibility first
		return (int) (1000 * (o.getPossibility() - this.getPossibility()));
	}

	public String getReview() {
		return review;
	}

	public void setReview(String review) {
		this.review = review;
	}
}
